package mebp.genetic.recombination;

import java.util.Vector;

import mebp.genetic.Individuum;

public class MinimumCrossover implements RecombinationStrategy {

	@Override
	public Vector<Individuum> recombine(Individuum... parents) {
		Individuum i1 = parents[0];
		Individuum i2 = parents[1];
		int genomLength = i2.genom.length;

		int child1[] = new int[genomLength];
		//int child2[] = new int[genomLength];

		System.arraycopy(i1.genom, 0, child1, 0, genomLength);
		//System.arraycopy(i2.genom, 0, child2, 0, genomLength);
	    
		for (int j = 0; j < genomLength; j++) {
			if (i1.genom[j]<=i2.genom[j]) {
				continue;
			} else {
				//child2[j] = i1.genom[j];
				child1[j] = i2.genom[j];
			}
		}

		Vector<Individuum> result = new Vector<Individuum>();
		
		Individuum ind1=new Individuum(i1.problem, child1);
		ind1.repair();
		if (i1.isSpanningTree()) 
			result.add(ind1);
		/*Individuum ind2=new Individuum(i1.problem, child2);
		ind2.repair();
		if (ind2.isSpanningTree()) 
			result.add(ind2);
		*/
		return result;
	}
}
